from sql import sqlseverDB
from threading import Thread
from config import *
from queue import Queue
import requests,re,json,concurrent.futures


ms=sqlseverDB('{SQL Server}', SQL_SERVER, 'SuMaiTongPol', SQL_USER, SQL_PWD)

upque=Queue(-1)
def main():

    with open('amkw.txt','r',encoding='utf-8') as f:

        cot=f.read()
    
    kws=[(kw.strip(),) for kw in cot.split('\n')]

    aff=ms.insert_datas(set(kws),'amazonkw',('kw',))

    aff2=ms.ExecNoQuery('update amazonkw set isuse=2 where id in (select min(id) from amazonkw group by kw)')
    print(f'本次总量:{aff}个,有效上传{aff2}个')
    aff3=ms.ExecNoQuery('delete from amazonkw where isuse!=2')
    print(f'删除重复:{aff3} 个')

main()

    